import request from '../utils/request'

export const getRoles = data => {
  return request({
    url: '/boss/role/getRolePages',
    method: 'POST',
    data
  })
}

export const deleteRole = id => {
  return request({
    url: `/boss/role/${id}`,
    method: 'DELETE'
  })
}

export const saveOrUpdate = data => {
  return request({
    url: '/boss/role/saveOrUpdate',
    method: 'POST',
    data
  })
}

// 获取角色信息
export const getRoleDetail = id => {
  return request({
    url: `/boss/role/${id}`,
    method: 'GET'
  })
}

// 获取所有角色信息
export const getAllRole = () => {
  return request({
    url: '/boss/role/all',
    method: 'GET'
  })
}

// 分配角色
export const allocateUserRoles = data => {
  return request({
    url: '/boss/role/allocateUserRoles',
    method: 'POST',
    data
  })
}

// 查询用户角色
export const getAllRoleById = userId => {
  return request({
    url: `/boss/role/user/${userId}`,
    method: 'GET'
  })
}
